-- $LastChangedDate: 2007-04-30 17:24:59 +0200 (Mon, 30 Apr 2007) $
-- $LastChangedRevision: 72 $
-- $LastChangedBy: david $

-- Obtenido de
-- http://www.cmis.brighton.ac.uk/~je/adacraft/appd.htm#d.8

with Ada.Finalization;
use  Ada.Finalization;
generic
   type Item_Type is private;
package List is
   type List_Type    is new Limited_Controlled with private;
   type List_Iterator is private;

   function Size  (List : List_Type) return Natural;
   function First (List : List_Type) return List_Iterator;
   function Last  (List : List_Type) return List_Iterator;

   function Succ  (Iterator : List_Iterator) return List_Iterator;
   function Pred  (Iterator : List_Iterator) return List_Iterator;
   function Value (Iterator : List_Iterator) return Item_Type;

   -- Inserta Item en predecesor del elemento apuntado por el iterator
   procedure Insert (Iterator : in List_Iterator; Item: in Item_Type);
   procedure Delete (Iterator : in List_Iterator);
   procedure Update (Iterator : in List_Iterator; Item: in Item_Type);

   List_Error : exception;

private
   type Item_Record;
   type Item_Access is access Item_Record;

   type Item_Record is
      record
         Item : Item_Type;
         Next : Item_Access;
         Pred : Item_Access;
      end record;
   type List_Header is
      record
         First : Item_Access;
         Last  : Item_Access;
         Count : Natural := 0;
      end record;
   type List_Access is access List_Header;

   type List_Type is new Limited_Controlled with
      record
         List : List_Access := new List_Header;
      end record;

   procedure Finalize (Object : in out List_Type);

   type List_Iterator is
      record
         List   : List_Access;
         Current : Item_Access;
      end record;

end List;
